<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>  
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<%@ include file="../common/StyleEUIMobile.jsp"%>
<title>千禧销售统计系统</title>
    <script>
        $(document).ready(function(){
        	
        	var params= $.serializeObject($('#preGenReportForm'));
        	
        	$('#dg').datagrid({
        		url : 'chainReportJSON!getSalesStatisticReptElesMB',
        		queryParams: params,
        		rownumbers: true,
        		lines : false,
        		columns : [ [
        			        {field:'name', width:80,title:'货品名称'},
        			        {field:'salesPrice', width:30,title:'吊牌价',
        						formatter: function (value, row, index){
        							if (row.salesPrice != 0)
        							   return (row.salesPrice).toFixed(0);
        							else 
        							   return "";
        						}
        					},
        					{field:'netQ', width:30,title:'净销量'},
        				    {field:'img',width:30,title:'',
          					  formatter : function(value, row, index) {
          						var str = '';
          						if(row.img != ""){
          							str += $.formatString('<a href="#" onclick="viewImgMobile(\'{0}\');"><img border="0" src="{1}" title="图片" width="70" height="70"/></a>', row.barcode,row.imgs);
          						}else {
          							str += $.formatString('<a href="#" onclick="goDetail({0},{1});">详情</a>', row.categoryLevelId,row.categoryId,'<%=request.getContextPath()%>/conf_files/easyUI/themes/icons/ok.png');
          						}
      							return str;
          					  }}
        			     ]],
        	});
        });

        function viewImgMobile(barcode){
        	var params= $('#preGenReportForm').serialize();

        	$('#dd').dialog({
        	    title: '条码：' + barcode +'详情',
        	    width: 350,
        	    height: 550,
        	    closed: false,
        	    cache: false,
        	    href: 'chainReportJSPAction!viewSalesStatisticDetailMB?formBean.barcode=' + barcode + "&"+params,
    
        	    modal: true,
        	    toolbar:[{
        	        text:'前一款',
        	        iconCls:'icon-undo',
        	        handler:function(){viewPrior();}
        	    },{
        	        text:'后一款',
        	        iconCls:'icon-redo',
        	        handler:function(){viewNext();}
        	    }],
    			buttons : [ {
    				text : '关闭窗口',
    				width : '100%',
    				handler : function() {
    					$('#dd').dialog('close');
    				}} 				
    			]
        	});
        	/*$('#dd').dialog({
    			title : '条码：' + barcode +'图片详情',
    			width : 450,
    			height : 450,
    			modal : false,
    			href : 'chainReportJSPAction!viewSalesStatisticDetailMB?formBean.barcode='
    					+ barcode,
    			buttons : [ {
    				text : '关闭窗口',
    				handler : function() {
    					$.modalDialog.handler.dialog('close');
    				}
    			} ]
    		});*/

        }
        
        function backPage(){
        	
        	if ($("#categoryId").val()!=0)
        		$("#categoryId").val("0");
        	else if ($("#categoryLevelId").val()!=0)
        		$("#categoryLevelId").val("0");
            document.preGenReportForm.action="chainReportJSPAction!preSalesStatisticReportMB";
            document.preGenReportForm.submit();
        }
		function goDetail(categoryLevelId, categoryId){
        	if (categoryId!=0)
        		$("#categoryId").val(categoryId);
        	else if (categoryLevelId!=0)
        		$("#categoryLevelId").val(categoryLevelId);
            document.preGenReportForm.action="chainReportJSPAction!preSalesStatisticReportMB";
            document.preGenReportForm.submit();
		}

        </script>
</head>
<body>
	<div class="easyui-navpanel" style="position:relative;padding:5px">
        <header>
           <div class="m-toolbar">
                <div class="m-title">千禧<s:property value="uiBean.reportTypeS"/></div>
                <div class="m-left">
                    <a href="javascript:backPage();" class="easyui-linkbutton m-back" plain="true" outline="true">返回上层</a>
                </div>
                <div class="m-right">
                    
                </div>

            </div>
        </header>
          <table id="dg" data-options="header:'#hh',singleSelect:true,border:false,fit:true,fitColumns:true,scrollbarSize:0">  
          </table>
       <div id="hh">
          <div class="m-toolbar">
            <div class="m-title"><s:property value="uiBean.reportTitleS"/>
            <s:form id="preGenReportForm" name="preGenReportForm" action=""
				theme="simple" method="POST">
				<s:hidden name="formBean.reportType" id="reportType"/>
				<s:hidden name="formBean.year.year_ID" id="yearId"/>
				<s:hidden name="formBean.quarter.quarter_ID" id="quarterId"/>
				<s:hidden name="formBean.categoryLevel1.category_ID" id="categoryLevelId"/>
            	<s:hidden  name="formBean.category.category_ID" id="categoryId"/>
			</s:form>
			</div>
          </div>
       </div>
       <div id="dd"></div>


        <jsp:include  page="ChainSalesStatisticFooter.jsp"/>

   
        
	</div>
</body>
</html>
